package com.array;

import java.util.Arrays;
import java.util.Comparator;

public class ArrayMethod01 {
    public static void main(String[] args) {
        Integer integers[] = {1,20,90,30,-10};

        //Arrays.toString 方法，显示数组
        System.out.println(Arrays.toString(integers));

        //2. sort 的使用方法

        Arrays.sort(integers);
        System.out.println("==排序后==");
        System.out.println(Arrays.toString(integers));

        //通过Comparator 实现定制排序,要求实现 compare方法
        Arrays.sort(integers, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });

        System.out.println("==实现定制排序后==");
        System.out.println(Arrays.toString(integers));
    }
}
